from ..book import ContentType, Content, TableContent


class Model:
    def make_text_prompt(self, text: str, target_language: str) -> str:
        return f"将{text}翻译为{target_language}"

    def make_table_prompt(self, table: str, target_language: str) -> str:
        return f"翻译为{target_language}，保持间距（空格，分隔符），以表格形式返回,不要以markdown形式返回：\n{table}"

    def translate_prompt(self, content: Content, target_language: str) -> str:
        if content.content_type == ContentType.TEXT:
            return self.make_text_prompt(content.original, target_language)
        elif content.content_type == ContentType.TABLE and isinstance(content, TableContent):
            return self.make_table_prompt(content.get_origin_as_str(), target_language)

    def make_image_prompt(self):
        pass

    def make_request(self, prompt):
        raise NotImplementedError('子类必须实现的构造方法')
